﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace _20170202_GameNode
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            Random rnd = new Random();
            //GameNode gn = new GameNode(6, 6);
            Drawer dr = new Drawer('@', 'H');
            GameField field = new GameField(10, 10, 4, 4);
            dr.DrawGameFieldFrame(field);

            Game checker = new Game();
            GameNode gn = new GameNode(checker.newNodeX(field), checker.newNodeY(field));
            dr.DrawNode(gn,ConsoleColor.Blue);
            Thread.Sleep(2000);
            GameNode gn2 = new GameNode(checker.newNodeX(field), checker.newNodeY(field));
            dr.DrawNode(gn2, ConsoleColor.Red);
            Thread.Sleep(2000);
            GameNode gn3 = new GameNode(checker.newNodeX(field), checker.newNodeY(field));
            dr.DrawNode(gn3, ConsoleColor.Yellow);
            Thread.Sleep(5000);
            //int randomX = field.StartX + rnd.Next(0, field.Width);
            //int randomY = field.StartY + rnd.Next(0, field.Height);


            for (int i = 0; i <500; i++)
            {
                switch (rnd.Next(1,5))
                {
                    case 1:
                        {
                            if (gn.Y > field.StartY)
                            {
                                gn.MoveUp();
                            }
                            break;
                        }
                    case 2:
                        {
                            if (gn.Y < field.StartY+field.Height-1)
                            {
                                gn.MoveDown();
                            }
                            break;
                        }
                    case 3:
                        {
                            if (gn.X > field.StartX)
                            {
                                gn.MoveLeft();
                            }
                            break;
                        }
                    case 4:
                        {
                            if (gn.X < field.StartX + field.Width-1)
                            {
                                gn.MoveRight();
                            }
                            break;
                        }
                }
                dr.DrawNode(gn, ConsoleColor.Red);
            }
        }

        //static int GenerateNodeX()
        //{
        //    Random rnd = new Random();
        //    int x =

        //}
    }
}
